#lambda 变量:表达式
#定义匿名函数
res1=lambda x,y:x+y#默认返回x+y
func=res1(1,2)
print(func)
res=(lambda x,y:x+y)(1,2)
print(res)

salaries={"siry":"3000","tom":"7000","lili":"10000","jack":"2000"}
#找出薪资最高的那个人
# res=max([3,200,11,300,399])
# print(res) 399
# res=max(salaries)
# print(res) tom 没有给定key(迭代依据)
#迭代出来的是人名:siry
salaries={"siry":3000,"tom":8000,"lili":700000,"jack":2000}
def func(k):
    return salaries[k]
res1=max(salaries,key=func)#不需要加括号，会自动调用，返回值=func('siry')
print(res1)
salaries={"siry":3000,"tom":8000,"lili":700000,"jack":2000}
res=max(salaries,key=lambda k:salaries[k])
print(res)
res2=sorted(salaries,key=lambda x:salaries[x])
print(res2)
print(dict(sorted(salaries.items(),key=lambda x:x[-1])))

salaries={"siry":3000,"tom":8000,"lili":700000,"jack":2000}
print(sorted(salaries, key=salaries.get))
for i in salaries:
    print(salaries.get(i))


